//
//  GNRGetMarksParam.m
//  Faceto
//
//  Created by LvYuan on 17/4/23.
//  Copyright © 2017年 LvYuan. All rights reserved.
//

#import "GNRGetMarksParam.h"
#import "GNRHelper.h"

@implementation GNRMarkDayModel

@end

@implementation GNRGetMarksParam

- (NSArray<GNRMarkDayModel *> *)mark_days{
    if ([self.content isKindOfClass:[NSDictionary class]]) {
        NSDictionary * content = self.content;
        if (content.allKeys.count) {
            //取出积分
            NSMutableArray * markDayModelArr = [NSMutableArray array];
            for (NSString * key in content.allKeys) {
                if (key && [GNRHelper isValidDateStr:key]) {
                    if ([content objectForKey:key]) {
                        GNRMarkDayModel * model = [[GNRMarkDayModel alloc]init];
                        model.dateStr = [NSString stringWithFormat:@"%@",key];
                        model.mark = [[content objectForKey:key] integerValue];
                        [markDayModelArr addObject:model];
                    }
                }
            }
            //从小到大排序
            [markDayModelArr sortUsingComparator:^NSComparisonResult(GNRMarkDayModel *  _Nonnull obj1, GNRMarkDayModel *  _Nonnull obj2) {
                 return [GNRHelper compareOneDay:obj1.dateStr withAnotherDay:obj2.dateStr];
            }];
            return markDayModelArr.mutableCopy;
        }
    }
    return nil;
}
@end
